﻿<Controls:SinacorWindow
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:Custom="http://schemas.xceed.com/wpf/xaml/datagrid"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	mc:Ignorable="d"
	xmlns:Controls="clr-namespace:Sinacor.Infra.UI.Controls.SmartClient;assembly=Sinacor.Infra.UI.Controls"
	
	WindowStartupLocation="CenterScreen"
    WindowState="Maximized"
	Title="{DynamicResource Bovespa.Alocacao.Label.DistribuicaoNegocios}"
	
	x:Class="Sinacor.UI.Bovespa.Alocacao.View.SmartClient.DistribuicaoNegocios"  
    ModulePlus="true" 
    ModuleId="ORD" >

    <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
        <Controls:SinacorExpanderContainer Width="Auto" Height="Auto">
            <Controls:SinacorExpanderContainer.RowDefinitions>
                <RowDefinition Height="122" />
                <RowDefinition Height="*" />
                <RowDefinition Height="*" />
            </Controls:SinacorExpanderContainer.RowDefinitions>
            <Controls:SinacorExpander Grid.Row="0"
									  HorizontalAlignment="Stretch"
									  VerticalAlignment="Stretch"
									  Header="{DynamicResource Bovespa.Alocacao.Label.Pesquisa}"
									  IsExpanded="True"
									  Height="Auto"
                                      x:Name="expPesquisa">
                <Grid>
                    <Controls:SinacorLabel HorizontalAlignment="Left" 
						Content="{DynamicResource Bovespa.Alocacao.Label.Pregao}" 
						Width="145" 
						Margin="0,8,0,0" 
						IsTargetFieldRequired="True"/>
                    <Controls:SinacorComboBox 
                        IsSynchronizedWithCurrentItem="True" 
						HorizontalAlignment="Left" 
						Margin="149,8,0,0" 
						VerticalAlignment="Top" 
						Width="142"
						TabIndex="1"
                        x:Name="cmbDataPregao"
                        ItemsSource="{Binding ListaCalendarios}"
                        IsRequired="True"
                        RequiredErrorMessage="FaturamentoBovespa.Movimento.ExceptionMessage.DataPregaoObrigatorio"
                        ItemStringFormat="d"
                        DisplayMemberPath="DataPregao"
                        SelectedValuePath="DataPregao"
                        />
                    <Controls:SinacorLabel HorizontalAlignment="Left" 
						Content="{DynamicResource Bovespa.Alocacao.Label.Ativo}" 
						Width="145" 
						Margin="0,58,0,0"/>
                    <Controls:SinacorTextBox HorizontalAlignment="Left" 
                                             Margin="149,58,0,0"
											 TabIndex="4" 
											 Width="115" 
											 VerticalAlignment="Top" 
											 MaxLength="12"
                                             x:Name="txtAtivo"
                                             CharacterCasing="Upper"
                                             Text="{Binding FiltroNegocioDistribuicao.CodigoNegocio}"
                                             />
                    <Controls:SinacorButton HorizontalAlignment="Left"
											Icon="IconButtonSearch"
											ToolTip="{DynamicResource Bovespa.Alocacao.Label.PesquisarAtivo}"
											Margin="268,58,0,0" 
											VerticalAlignment="Top" 
                                            x:Name="btnPesquisarAtivo"
                                            OnBufferedClick="btnPesquisarAtivo_OnBufferedClick"
											TabIndex="5"/>
                    <Controls:SinacorLabel 
										   Content="{DynamicResource Bovespa.Alocacao.Label.Cliente}" 
										   VerticalAlignment="Top"
                                           Width="145"
                                           Margin="0,33,0,0" 
										   HorizontalAlignment="Left"
                                           IsTargetFieldRequired="True"/>
                    <Controls:SinacorInt64TextBox Margin="149,33,0,0"  
                                                     TabIndex="2"  
                                                     Width="115" 
													 VerticalAlignment="Top" 
													 HorizontalAlignment="Left" 
													 Integers="7"
                                                     IsFormated="False"
                                                     IsRequired="True"
                                                     RequiredErrorMessage="Bovespa.Cliente.ExceptionMessage.ClienteInvalido" 
                                                     x:Name="txtCliente" 
                                                     Value="{Binding FiltroNegocioDistribuicao.Cliente}"
                                                     />
                    <Controls:SinacorButton HorizontalAlignment="Left"
                                                    Icon="IconButtonClient"
                                                    ToolTip="{DynamicResource Bovespa.Alocacao.Label.PesquisarCliente}"
                                                    x:Name="btnPesquisarCliente"
                                                    OnBufferedClick="btnPesquisarCliente_OnBufferedClick" 
                                                    Margin="268,33,0,0" 
                                                    TabIndex="3" 
													VerticalAlignment="Top"/>

                    <Controls:SinacorGroupBox VerticalAlignment="Top"
											  Header="{DynamicResource Bovespa.Alocacao.Label.NumeroNegocio}"
											  Width="170"
											  Height="79"
											  Margin="295,0,0,0" 
											  HorizontalAlignment="Left" >
                        <Grid Width="Auto" Height="Auto" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,-2,0,0">
                            <Controls:SinacorLabel HorizontalAlignment="Left" 
            					Width="70" 
            					VerticalAlignment="Top" 
								Content="{DynamicResource Bovespa.Alocacao.Label.De}"/>
                            <Controls:SinacorInt64TextBox 
            					Margin="74,0,0,0" 
            					Width="77" 
            					TabIndex="6" 
            					VerticalAlignment="Top" 
								HorizontalAlignment="Left" 
								Integers="9" 
								IsFormated="False" 
                                x:Name="txtDe"
                                Value="{Binding FiltroNegocioDistribuicao.NumeroNegocioDe}"
                                />
                            <Controls:SinacorLabel HorizontalAlignment="Left" 
            					Width="70" 
            					VerticalAlignment="Top" 
            					Content="{DynamicResource Bovespa.Alocacao.Label.Ate}" 
								Margin="0,25,0,0" />
                            <Controls:SinacorInt64TextBox Margin="74,25,0,0" 
            					Width="77" 
            					TabIndex="7" 
								HorizontalAlignment="Left" 
								VerticalAlignment="Top" 
								Integers="9" 
								IsFormated="False" 
                                x:Name="txtAte" 
                                Value="{Binding FiltroNegocioDistribuicao.NumeroNegocioAte}"
                                />
                        </Grid>
                    </Controls:SinacorGroupBox>
                    <Controls:SinacorGroupBox Header="{DynamicResource Bovespa.Alocacao.Label.NaturezaOperacao}"
            			Width="427"
            			Height="49"
            			Margin="469,0,0,0" 
            			HorizontalAlignment="Left" 
            			VerticalAlignment="Top" >
                        <Grid Width="Auto" Height="Auto" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,-3,0,0">
                            <Controls:SinacorRadioButton HorizontalAlignment="Left" 
            					VerticalAlignment="Top" 
            					Content="{DynamicResource Bovespa.Alocacao.Label.Compra}" 
                                x:Name="RblCompra"
            					Width="125" 
            					TabIndex="8"/>
                            <Controls:SinacorRadioButton HorizontalAlignment="Left" 
            					VerticalAlignment="Top" 
            					Content="{DynamicResource Bovespa.Alocacao.Label.Venda}" 
            					Width="120" 
            					Margin="129,0,0,0" 
            					TabIndex="9"
                                x:Name="RblVenda"/>
                            <Controls:SinacorRadioButton VerticalAlignment="Top" 
            					Content="{DynamicResource Bovespa.Alocacao.Label.CompraVenda}" 
            					Width="160" 
            					Margin="253,0,0,0" 
            					HorizontalAlignment="Left" 
            					TabIndex="10" 
            					IsChecked="True"
                                x:Name="RblCompraVenda"/>
                        </Grid>
                    </Controls:SinacorGroupBox>
                    <Controls:SinacorButton HorizontalAlignment="Left"
            			Margin="680,58,0,0"
            			Width="106"
            			Content="{DynamicResource Bovespa.Alocacao.Label.Pesquisar}"
            			VerticalAlignment="Top"
            			IsDefault="True"
                        CausesValidation="True"
            			TabIndex="11"                                            
                        x:Name="BtnPesquisa"
                        Click="BtnPesquisa_Click"                   
                        />
                    
                    <Controls:SinacorButton HorizontalAlignment="Left"
            			Margin="790,58,0,0"
            			Width="106"
            			Content="{DynamicResource Bovespa.Alocacao.Label.NovaPesquisa}"
            			VerticalAlignment="Top"
            			TabIndex="12" 
                        x:Name="BtnNovaPesquisa"
                        Click="BtnNovaPesquisa_Click"               
                        />
                </Grid>
            </Controls:SinacorExpander>
            <Controls:SinacorExpander Grid.Row="1"
									  HorizontalAlignment="Stretch"
									  VerticalAlignment="Stretch"
									  Header="{DynamicResource Bovespa.Alocacao.Label.NegociosDistribuidos}"
									  IsExpanded="True" 
									  Margin="0,4,0,0">
                <Grid>

                    <Controls:SinacorDataGrid x:Name="dtgNegociosDistribuidos"
                                              ItemsSource="{Binding ListaDistribuidos}"
											  HorizontalAlignment="Stretch"
											  Width="Auto"						
											  VerticalAlignment="Stretch" 										
											  Margin="0,0,0,0"
											  AllowBeginInsert="False" 
                            				  AllowBeginUpdate="False"
											  AllowCancelInsert="False"
											  AllowCancelUpdate="False"
											  AllowSave="False" 
											  AllowDelete="False"  
											  TabIndex="13" 
                                              ApplyingStyle="dtgNegociosDistribuidos_ApplyingStyle"
                                              SelectionMode="Extended"
                                              >
                        <Controls:SinacorDataGrid.ContextMenuTemplate>
                            <DataTemplate>
                                <StackPanel>
                                    <Controls:SinacorContextMenuItem 
                                        x:Name="ContextMenu_CancelarDistribuicao" 
                                        Header="{DynamicResource Bovespa.Alocacao.Label.CancelarDistribuicao}"
                                        Click="ContextMenu_CancelarDistribuicao_Click"
                                        Loaded="ContextMenu_CancelarDistribuicao_Loaded"
                                        
                                        />
                                </StackPanel>
                            </DataTemplate>
                        </Controls:SinacorDataGrid.ContextMenuTemplate>
                        <Controls:SinacorDataGrid.Columns>
                            <!---->
                            <Controls:Column Name="Cliente"  
    										 Title="Bovespa.Alocacao.Label.Cliente"
                                             DisplayMemberPath="DadosDistribuicao.Cliente"
                                             HorizontalCellAlignment="Right" 
                                             />
                            <Controls:Column Name="Broker" 
    										 Title="Bovespa.Alocacao.Label.Broker"
                                             DisplayMemberPath="DadosDistribuicao.ClienteBroker" 
                                             HorizontalCellAlignment="Right" 
                                             />
                            <Controls:Column Name="Ativo" 
    										 Title="Bovespa.Alocacao.Label.Ativo" 
                                             DisplayMemberPath="NegocioNaoDistribuido.Codigo" 
                                             />
                            <Controls:Column Name="NaturezaOperacao" 
    										 Title="Bovespa.Alocacao.Label.NatOperacao"
                                             DisplayMemberPath="NegocioNaoDistribuido.NaturezaOperacao"
                                             />
                            <Controls:Column Name="NumeroNegocio" 
    										 Title="Bovespa.Alocacao.Label.NNegocio"
                                             DisplayMemberPath="NegocioNaoDistribuido.Numero" 
                                             HorizontalCellAlignment="Right" 
                                             />
                            <Controls:Column Name="Preco" 
    										 Title="Bovespa.Alocacao.Label.Preco" 
                                             DisplayMemberPath="NegocioNaoDistribuido.Preco"
                                             HorizontalCellAlignment="Right" 
                                             StringFormat="N2"
                                             />
                            <Controls:Column Name="Quantidade" 
    										 Title="Bovespa.Alocacao.Label.Quantidade"
                                             DisplayMemberPath="DadosDistribuicao.QuantidadeEspecificar"
                                             HorizontalCellAlignment="Right" 
                                             />
                            <Controls:Column Name="TipoLiquidacao" 
    										 Title="Bovespa.Alocacao.Label.TipoLiq" 
                                             DisplayMemberPath="DadosDistribuicao.Direcionado.TipoLiquidacao"
                                             />
                            <Controls:Column Name="Carteira" 
    										 Title="Bovespa.Alocacao.Label.Carteira" 
                                             DisplayMemberPath="DadosDistribuicao.Carteira"
                                             HorizontalCellAlignment="Right" 
                                             />
                            <Controls:Column Name="Mercado" 
    										 Title="Bovespa.Alocacao.Label.Mercado" 
                                             DisplayMemberPath="DadosDistribuicao.Mercado"
                                             />
                            <Controls:Column Name="Bolsa" 
    										 Title="Bovespa.Alocacao.Label.Bolsa" 
                                             DisplayMemberPath="DadosDistribuicao.Bolsa"
                                             HorizontalCellAlignment="Right" 
                                             />
                            <Controls:Column Name="UsuarioDirecionado" 
    										 Title="Bovespa.Alocacao.Label.UsuarioDirecionado" 
                                             DisplayMemberPath="DadosDistribuicao.Direcionado.Usuario"
                                             HorizontalCellAlignment="Right" 
                                             />
                            <Controls:Column Name="ClienteDirecionado" 
    										 Title="Bovespa.Alocacao.Label.ClienteDirecionado" 
                                             DisplayMemberPath="DadosDistribuicao.Direcionado.Cliente"
                                             HorizontalCellAlignment="Right" 
                                             />
                            <Controls:Column Name="DV" 
    										 Title="Bovespa.Alocacao.Label.DV" 
                                             DisplayMemberPath="DadosDistribuicao.Direcionado.DigitoVerificadorCliente"
                                             HorizontalCellAlignment="Right" 
                                             />
                            <Controls:Column Name="PercReducaoAcrescimo" 
    										 Title="Bovespa.Alocacao.Label.PerRedAcr" 
                                             DisplayMemberPath="DadosDistribuicao.Direcionado.PercentualReducaoAcrescimo"
                                             HorizontalCellAlignment="Right" 
                                             />
                            <Controls:Column Name="Dolar" 
    										 Title="Bovespa.Alocacao.Label.Dolar" 
                                             DisplayMemberPath="DadosDistribuicao.Dolar"
                                             HorizontalCellAlignment="Right" 
                                             StringFormat="N2"
                                             />
                            <Controls:Column Name="IndLiquidacaoExternaCliente" 
    										 Title="Bovespa.Alocacao.Label.IndLiqExternaCliente" 
                                             DisplayMemberPath="DadosDistribuicao.IndicadorLiquidacaoExternaCliente"
                                             />
                            <!---->
                            <Controls:Column Name="IndSistemaExterno" 
    										 Title="Bovespa.Alocacao.Label.IndSistemaExterno2" 
                                             DisplayMemberPath="DadosDistribuicao.IndicadorSistemaExterno"
                                             />
                        </Controls:SinacorDataGrid.Columns>
                    </Controls:SinacorDataGrid>

                </Grid>
            </Controls:SinacorExpander>
            <Controls:SinacorExpander Grid.Row="2"
            	HorizontalAlignment="Stretch"
            	VerticalAlignment="Stretch"
            	Header="{DynamicResource Bovespa.Alocacao.Label.NegociosDisponiveis}"
            	IsExpanded="True" 
				Margin="0,4,0,0">
                <Grid>
                    <Controls:SinacorDataGrid 
                        x:Name="dtgNegociosDisponiveis"
                        ItemsSource="{Binding ListaDisponiveis}"
                        SelectionMode="Extended"                      
            			HorizontalAlignment="Stretch"
            			Width="Auto"							
            			VerticalAlignment="Stretch" 										
            			Margin="0,0,0,0"
            			AllowBeginInsert="False" 
            			AllowBeginUpdate="False"
            			AllowCancelInsert="False"
            			AllowCancelUpdate="False"
            			AllowSave="False" 
            			AllowDelete="False"  
            			TabIndex="14" 
						IsGroupable="True"
                        SelectionChanged="dtgNegociosDisponiveis_SelectionChanged">
                        <Controls:SinacorDataGrid.ContextMenuTemplate>
                            <DataTemplate>
                                <StackPanel>
                                    <Controls:SinacorContextMenuItem x:Name="ContextMenu_DigitarDistribuicao" Header="{DynamicResource Bovespa.Alocacao.Label.DigitarDistribuicao}"
                                     Click="ContextMenu_DigitarDistribuicao_Click"
                                                                     Loaded="ContextMenu_DigitarDistribuicao_Loaded"/>
                                </StackPanel>
                            </DataTemplate>
                        </Controls:SinacorDataGrid.ContextMenuTemplate>
                        <Controls:SinacorDataGrid.Columns>
                            <Controls:Column Name="Broker" 
            					             Title="Bovespa.Alocacao.Label.Broker" 
                                             DisplayMemberPath="ClienteBroker"
                                             HorizontalCellAlignment="Right" 
                                             />
                            <Controls:Column Name="Ativo"                                             
            				                 Title = "Bovespa.Alocacao.Label.Ativo" 
                                             DisplayMemberPath="Codigo"
                                             />
                            <Controls:Column Name="NaturezaOperacao"
            					             Title="Bovespa.Alocacao.Label.NatOperacao" 
                                             DisplayMemberPath="NaturezaOperacao"
                                             />
                            <Controls:Column Name="NumeroNegocio" 
            					             Title="Bovespa.Alocacao.Label.NNegocio" 
                                             DisplayMemberPath="Numero"
                                             HorizontalCellAlignment="Right"
                                             />
                            <Controls:Column Name="Preco" 
            					             Title="Bovespa.Alocacao.Label.Preco" 
                                             DisplayMemberPath="Preco"
                                             HorizontalCellAlignment="Right"
                                             StringFormat="N2"
                                             />
                            <Controls:Column Name="Quantidade" 
            					             Title="Bovespa.Alocacao.Label.Quantidade" 
                                             DisplayMemberPath="Quantidade"
                                             HorizontalCellAlignment="Right"
                                             />
                            <Controls:Column Name="Saldo" 
            					             Title="Bovespa.Alocacao.Label.Saldo" 
                                             DisplayMemberPath="Saldo"
                                             HorizontalCellAlignment="Right"
                                             />
                            <Controls:Column Name="Bolsa" 
            					             Title="Bovespa.Alocacao.Label.Bolsa" 
                                             DisplayMemberPath="Bolsa"
                                             HorizontalCellAlignment="Right"
                                             />
                            <Controls:Column Name="Mercado" 
            					             Title="Bovespa.Alocacao.Label.Mercado" 
                                             DisplayMemberPath="Mercado"
                                             />
                        </Controls:SinacorDataGrid.Columns>
                    </Controls:SinacorDataGrid>
                </Grid>
            </Controls:SinacorExpander>
        </Controls:SinacorExpanderContainer>
    </Grid>
</Controls:SinacorWindow>
